import fetch from '@/utils/network/fetch'
  
  // 分页获取列表内容    
const getstudyExam = (data, objc) => {
    data &&
        fetch('/api/exam', {
            ...objc,
            method: 'post',
            data
        })
}

  // 删除某一条列表
const removeoneExam = (lIds, objc) => {
    lIds &&
        fetch('/api/exam/deletion', {
            ...objc,
            method: 'post',
            data: { lIds }
        })
}
 
 // 创建任务
const createExam=(data, objc)=>{
    data &&
     fetch('/api/exam',{
        data,
        method:'put',
        ...objc
     })
}

// 根据ID 查询单个任务
const queryOneExam=(lIds, objc)=>{
    lIds && 
     fetch('/api/exam/'+lIds,{
        method:'get',
        ...objc
     })
}

// 根据ID添加考试试卷关系
const addPaperRelation = (data, objc) => {
    data && 
     fetch(`/api/exam/${data.id}/paper_relation`, {
        data,
        method:'put',
        ...objc
     })
}

// 根据ID添加考试学员关系
const addTraineeRelation = (data, objc) => {
    data && fetch(`/api/exam/${data.id}/trainee_relation`, {
        data,
        method: 'put',
        ...objc
    })
}

const updateExam = (data, objc) => {
    data && fetch(`/api/exam/${data.id}`, {
        data,
        method: 'put',
        ...objc
    })
}

// 考试中心，已完成考试
const examStore=(data, objc)=>{
    data && fetch('/api/learningrecords/exam-finished',{
            ...objc,
            method: 'post',
            data
        
    })
}

// 考试详细信息
const examDetail=(data,objc)=>{
    data && fetch('/api/learningrecords/exam-info',{
            ...objc,
            method: 'post',
            data
        
    })
}
export default {
    getstudyExam,
    removeoneExam,
    createExam,
    queryOneExam,
    updateExam,
    addPaperRelation,
    addTraineeRelation,
    examStore,
    examDetail
}
